home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / errorchk.arc / ERRORCHK.ASM
Assembly Source File  |  1988-08-09  |  3KB  |  101 lines

  1. Submitted-by: uunet!mcvax!philmds!leo (Leo de Wit)
  2. Posting-number: Volume 1, Issue 54
  3. Archive-name: errorchk
  4.  
  5. Here is another small memory-resident program to be placed in the AUTO folder.
  6.     Did you also had times you wanted to see a program's final (error?) message
  7. when it flashed over your screen and the desktop was painted all over it.
  8.     This little program checks whenever a program exits if the caller was the
  9. desktop (it does this by following the links in the basepages); if so, a 
  10. message is printed and you can press a key to continue.
  11.     The program sets the GEM program exit vector that is at address 0x408; this
  12. vector usually points to a RTS statement (i.e. does nothing). After a keypress
  13. a jump is made to the old vector (in case it WAS used).
  14.     This program also prevents the need of coding similar messages into every 
  15. program that can be called from the desktop.
  16.     It was assembled using the assembler and linker that come with the GST-C
  17. compiler, resulting in a program length of 240 bytes. 
  18.  
  19.     My name and address:
  20.  
  21.    L.J.M. de Wit
  22.    Nachtegaallaan 7
  23.    5731XP Mierlo
  24.    Holland.
  25.  
  26. ---------------  H E R E   I T   A L L   S T A R T S  -------------------------
  27.  
  28.  
  29.       MODULE  DTOPWAIT
  30.       SECTION S.CCODE
  31.  
  32. GEMDOS    EQU 1
  33. BIOS      EQU 13
  34. PTERMRES  EQU $31
  35. SETEXC    EQU 5
  36. ESC       EQU $1B
  37.  
  38. DTWINIT
  39.       MOVE.L   #-1,-(SP)
  40.       MOVE.W   #$102,-(SP)
  41.       MOVE.W   #SETEXC,-(SP)
  42.       TRAP     #BIOS             * Save old GEM exit vector
  43.       ADDQ.L   #8,SP
  44.       LEA.L    OLDVEC(PC),A0
  45.       MOVE.L   D0,(A0)
  46.       PEA      DTOPWAIT
  47.       MOVE.W   #$102,-(SP)
  48.       MOVE.W   #SETEXC,-(SP)
  49.       TRAP     #BIOS             * Set new GEM exit vector
  50.       ADDQ.L   #8,SP
  51.       MOVE.L   4(SP),A0
  52.       MOVE.L   #$100,D0          * Base page
  53.       ADD.L    12(A0),D0         * + text length
  54.       ADD.L    20(A0),D0         * + data length
  55.       ADD.L    28(A0),D0         * + bss length
  56.       CLR.W    -(SP)             * Return value: 0 for success
  57.       MOVE.L   D0,-(SP)          * # bytes to keep
  58.       MOVE.W   #PTERMRES,-(SP)   * Keep process
  59.       TRAP     #GEMDOS           * Stops here...
  60.  
  61. DTOPWAIT
  62.       MOVE.L   $602C,A0
  63.       MOVEQ.L  #0,D1
  64.       BRA.S    DTOPAREND
  65. DTOPARNT
  66.       ADDQ.L   #1,D1
  67.       MOVE.L   36(A0),A0
  68. DTOPAREND
  69.       TST.L    (A0)
  70.       BNE.S    DTOPARNT
  71.       CMP.B    #3,D1
  72.       BNE.S    DTWEND
  73.       LEA      WAITMSG(PC),A4
  74.       BRA.S    DTOPW3
  75. DTOPW2
  76.       EXT.W    D0
  77.       MOVE.W   D0,-(SP)
  78.       MOVE.W   #2,-(SP)
  79.       MOVE.W   #3,-(SP)
  80.       TRAP     #BIOS
  81.       ADDQ.L   #6,SP
  82. DTOPW3
  83.       MOVE.B   (A4)+,D0
  84.       BNE.S    DTOPW2
  85.       MOVE.W   #2,-(SP)
  86.       MOVE.W   #2,-(SP)
  87.       TRAP     #BIOS
  88.       ADDQ.L   #4,SP
  89. DTWEND
  90.       MOVE.L   OLDVEC(PC),-(SP)
  91.       RTS
  92.  
  93.       SECTION  S.DATA
  94.  
  95. OLDVEC   DC.L  0
  96. WAITMSG  DC.B  13,10,ESC,'K',ESC,'p',9,9
  97.          DC.B  'Program finished; hit a key to return to desktop',ESC,'q',0
  98.  
  99.       END
  100.  
  101.